#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,n)  for(int i = 1; i <= n; i ++)
#define pb push_back
#define pii pair<int,int>
#define endl "\n"
#define all(x) (x).begin(),(x).end()
int dx[5] = {0, -1, 1, 0, 0};
int dy[5] = {0, 0, 0, -1, 1};
const int MOD = 1e9+7;
const int N = 1e6+10;

void solve() {
	int n;
	cin>>n;
	vector<vector<int>>a(n+1,vector<int>(n+1,0));
	vector<vector<int>>dp(n+1,vector<int>(n+1,LLONG_MIN));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=i;j++){
			cin>>a[i][j];
		}
	}
	dp[1][1]=a[1][1];
	for(int i=2;i<=n;i++){
		for(int j=1;j<=i;j++){
			dp[i][j]=a[i][j]+max(dp[i-1][j],dp[i-1][j-1]);
		}
	}
	int ans=LLONG_MIN;
	f(i,n)ans=max(ans,dp[n][i]);
	cout<<ans<<endl;
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//scanf("%d", &t);
	//cin >> t;
	while (t--) solve();
	return 0;
}